// 每10个时钟周期，led翻转一次
module led_demo # (
    parameter PERIOD = 10
)
(
	input clk,
	input rst_n,
	output reg led
);

reg [7:0] cnt;

always @ (posedge clk) begin
	if(!rst_n)
		cnt <= 0;
	else if(cnt == PERIOD - 1)
		cnt <= 0;
	else 
		cnt <= cnt + 1;
end

always @ (posedge clk) begin
	if(!rst_n)
		led <= 0;
	else if(cnt == PERIOD - 1)
		led <= !led;
end

endmodule 